package design;

/**
 * @description: 模板设计模式
 * @author: apple
 * @date:  2021/11/24 12:16 上午
 * @version 1.0
 **/
public class TemplateTest {

    public static void main(String[] args) {

        MyTemplate t = new SubTemplate();
        t.spendTime();
    }
}

abstract class MyTemplate {
     void spendTime() {
        long start = System.currentTimeMillis();
        code();
        long end = System.currentTimeMillis();
        System.out.println("时间差为：" + (end - start));
    }

     abstract void code();

}

class SubTemplate extends MyTemplate {

    @Override
    void code() {
        System.out.println("SubTemplate method");
    }
}

